#include "flowpage.h"
#include<QPainter>
#include<QPixmap>
#include<QDebug>
#include<QMouseEvent>
#include<QBrush>
#include<QPen>
#include"mydata.h"

FlowPage::FlowPage(QWidget *parent) : QWidget(parent)
{

}

void FlowPage::paintEvent(QPaintEvent *)
{
    QPainter painter;
    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    QPen pen;


    QPixmap pix(":/Image/RoadMap.jpg");
    painter.begin(&pix);

    int roundCount = MyData::getObject()->roundCount();
    for(int i = 0;i<roundCount;i++)
    {
        Round * r =MyData::getObject()->getRound(i);
        brush.setColor(r->color);
        pen.setColor(r->color);
        painter.setBrush(brush);
        painter.setPen(pen);
        painter.drawRect(r->x,r->y,r->w,r->h);
    }
    painter.end();
     painter.begin(this);
    painter.drawPixmap(0,0,width(),height(),pix);
    painter.end();
}

void FlowPage::mousePressEvent(QMouseEvent *e)
{
    qDebug()<<e->pos();
}
